package com.gitee.wsl.exception

//import java.io.PrintWriter
//import java.io.StringWriter

class InitException(s: String, cause: Exception) : Throwable()

class MissingPermissionException : Throwable()

fun logTag(vararg tags: String): String {
    val sb = StringBuilder("\uD83D\uDC19:")
    for (i in tags.indices) {
        sb.append(tags[i])
        if (i < tags.size - 1) sb.append(":")
    }
    return sb.toString()
}

fun Throwable.asLog(): String {
   /* val stringWriter = StringWriter(256)
    val printWriter = PrintWriter(stringWriter, false)
    printStackTrace(printWriter)
    printWriter.flush()
    return stringWriter.toString()*/
    return stackTraceToString()
}

fun Throwable.getStackTracePeek() = this.stackTraceToString()
    .lines()
    .filterIndexed { index, _ -> index > 1 }
    .take(3)
    .joinToString("\n")

/**
 * @param message
 * @param lineNo
 */
// Todo: This needs a better name
internal class IllegalEncodingTypeException(message: String, lineNo: Int) : RuntimeException("Line $lineNo: $message")
